from django.shortcuts import render

# Create your views here.

from rest_framework.response import Response
from rest_framework.views import APIView
from home import models,homeser
class NavView(APIView):
    def get(self,request):
        pos=request.query_params.get("pos")
        navlist=models.NavModel.objects.filter(position=pos,isshow=True)
#         序列化数据
        ser=homeser.NavSerializer(navlist,many=True)
        return Response({"msg":"ok","data":ser.data})


class BannerView(APIView):
    def get (self,request):
        bannerlist=models.BannerModel.objects.filter(isshow=True)
        ser=homeser.BannerSer(bannerlist,many=True)
        return Response({"msg":"ok","data":ser.data})